#[derive(Debug)]
struct Node {
    val: i32,
    next: Option<Box<Node>>
}
impl Node {
    fn new(val: i32, next: Option<Box<Node>>) -> Node {
        Node {
            val,
            next
        }
    }
}

#[derive(Debug)]
struct List {
    head: Option<Box<Node>>,
    sz: i32
}


impl List {
    fn new()-> List {
        List{
            head: Some(Box::new(Node::new(0, None))),
            sz: 0
        }
    }

    /*
    fn push_front(&mut self, v: i32) {
        //let new_node = List::Node(v, Box::new(List::Nil))
        match self {
            List::Node(_, next) => {
                next = List::Node(v, Box::new(List::Nil));
            }
            List::Nil => {
            }
        };
    }*/
    fn print(&self) {
        let mut ptr = &(self.head);
        loop {
            match ptr {
                Option::Some(node) => {
                    println!("{:?}", node);
                    ptr = &(node.next);
                }
                None => {
                    break;
                }
            };
        }
    }
}
fn use_list_node() {
    let head = List::new();
    head.print();
    println!("head:{:?}", head);
}


/*
#[derive(Debug)]
struct List {
    head: String,
    sz: u32
}

impl List {
    fn new()-> List {
        List {
            head: String::from("hello"),
            sz: 0
        }
    }
    fn size(&self) -> u32{
        self.sz
    }
    fn set_size(&mut self, sz: u32){
        self.sz = sz;
    }
}*/

pub fn use_list(){
  //  let mut l = List::new();
  //  println!("sz:{}, List:{:?}", l.size(), l);
  //  l.set_size(10);
  //  println!("after set_size, List:{:?}", l);

    use_list_node();
}
